package com.butang.service;

import com.butang.AOP.Log;
import com.butang.mapper.EmpMapper;
import com.butang.pojo.Dept;
import com.butang.pojo.Emp;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

/**
 * ClassName: EmpServiceImpl
 * Package: com.butang.service
 * Description:
 *
 * @Author BuTang
 * @Create 2023/7/9 23:06
 * @Version 1.0
 */
@Service
public class EmpServiceImpl implements EmpService {
    @Autowired
    private EmpMapper empMapper;


    @Override

    public List<Emp> list(Integer page, Integer pageSize, String name, Short gender, LocalDateTime begin, LocalDateTime end) {
        int start =( page - 1 )* pageSize;
        List<Emp> list = empMapper.list(start,pageSize,name,gender, begin,end);
        return list;
    }

    @Override
    public Emp login(Emp emp) {
        Emp e = empMapper.login(emp);
        return e;
    }


    @Override
    public int count() {
        int count = empMapper.count();
        return count;
    }
    @Log
    @Override
    public void empDelete(List<Integer> ids) {
        empMapper.empDelete(ids);
    }
    @Log
    @Override
    public void add(Emp emp) {
        emp.setCreateTime(LocalDateTime.now());
        emp.setUpdateTime(LocalDateTime.now());
        empMapper.add(emp);
    }

    @Override
    public Emp getEmp(Integer id) {
        Emp emp = empMapper.getEmp(id);
        return emp;
    }
    @Log
    @Override
    public void update(Emp emp) {
        empMapper.update(emp);
    }
    @Log
    @Override
    public void delete(Integer id) {
        empMapper.delete(id);
    }


}
